<template>
  <div class="balance">
    <!-- 提现 -->
    <div class="balance_box">
      <div>提现余额</div>
      <div>
        &yen;<input
          type="digit"
          placeholder="输入金额"
          class="input"
          @input="onKeyInput"
        >
      </div>
      <div>
        <span>可用金额{{user.balance}}元</span>
        <span @click="ToDetailed">提现明细</span>
      </div>
    </div>

    <!-- 确定提现 -->
    <div @click="Extract()">确定提现</div>

  </div>
</template>

<script>
export default {
  props: {

  },
  data() {
    return {
      user: '',
      inputMoney: '',
    };
  },
  onShow() {
    let mobile =  wx.getStorageSync("mobile")
    this.request({
      url: this.baseUrl + '/api/edit/waterUser',
      data:{
        type: 1,
        mobile: mobile
      },
      method: 'POST',
    })
    .then(result=>{
			console.log(result)
			if(result.status == 200){
        this.user = result.data.user_login
			} else {
        return false
			}
    })
    // this.user = wx.getStorageSync('userInfo')
  },
  computed: {

  },
  created() {

  },
  mounted() {

  },
  watch: {

  },
  methods: {
    //跳转提现明细页面
    ToDetailed() {
      wx.navigateTo({
        url: '../detailed/main'
      })
    },
    onKeyInput: function(event) {
      this.inputMoney = event.target.value
    },
    Extract() {
      // /api/wechatapp/UserExtract
      this.request({
        url: this.baseUrl + '/api/wechatapp/UserExtract',
        data:{
          id: this.user.id,
          money: this.inputMoney,
        },
        method: 'POST',
      })
      .then(result=>{
        // console.log(result)
        if(result.status == 200){
          return true
        } else {
          return false
        }
      })
    },

  },
  components: {

  },
};
</script>

<style scoped >
.balance_box {
  background: #ffffff;
  margin-top: 20rpx;
}
.balance_box > div:nth-child(1) {
  padding: 20rpx;

  font-family: PingFangSC-Regular, PingFang SC;
}
.balance_box > div:nth-child(2) {
  padding: 20rpx;
  font-size: 60rpx;
  display: flex;
  font-family: Helvetica;
  margin-top: 30rpx;
  border-bottom: 1px solid #f5f5f5;
}
.input {
  height: 70rpx;
  line-height: 70rpx;
  margin-left: 20rpx;
}
.balance_box > div:nth-child(3) {
  display: flex;
  justify-content: space-between;
  padding: 20rpx;
}
.balance_box > div:nth-child(3) > span:nth-child(1) {
  color: #999999;
}
.balance_box > div:nth-child(3) > span:nth-child(2) {
  color: #1677ff;
}
.balance > div:nth-child(2) {
  /* margin: 50rpx; */
  padding: 25rpx;
  text-align: center;
  margin: 50rpx 30rpx;
  background: #1677ff;
  color: #ffffff;

  border-radius: 12rpx;
}
</style>
